<style>
/* 调色板样式 */
#colorBoard{position:absolute; padding:10px; width:256px; height:220px; background:#f3f3f3; border:#d9d9d9 1px solid;}
#colorBank{ clear:both; border:#d9d9d9 1px solid; background:#FFF; width:252px; padding:0 0 2px 2px; overflow:hidden; margin:0 auto 0 auto;}
#colorBank div{ overflow:hidden; height:12px; width:12px; margin:2px 2px 0 0; float:left; overflow:hidden; cursor:pointer;}
#colorViews{width:80px; height:20px; float:left;border:#d9d9d9 1px solid; background:#000; display:block; margin: 0 10px 10px 0;}
#colorInput{width:70px; height:18px; float:left; font-family:Verdana; font-size:13px; color:#333; display:block; border:none; background:#FFF;border:#d9d9d9 1px solid;margin: 0 10px 10px 0;}
#colorClose{width:80px; color:#999999; height:22px; float:left;display:block; background:#f3f3f3;cursor:pointer;border:#d9d9d9 1px solid; border-top:#FFF 1px solid; border-left:#FFF 1px solid;}
</style>
<!-- 主容器 -->
<div class="w660">
		<div class="smallCon">
			<h1>风格设计</h1>
			<ul class="listEdit">
				<li onmouseover="$(this).addClass('sel');" onmouseout="$(this).removeClass('sel');"><a href="<?=c('site_url');?><?=$site['domain'];?>/setting">轻站信息</a></li>
				<li class="sel"><a href="<?=c('site_url');?><?=$site['domain'];?>/setting/skin">风格设计</a></li>
				<li onmouseover="$(this).addClass('sel');" onmouseout="$(this).removeClass('sel');"><a href="<?=c('site_url');?><?=$site['domain'];?>/setting/member">成员管理</a></li>
				<li onmouseover="$(this).addClass('sel');" onmouseout="$(this).removeClass('sel');"><a href="<?=c('site_url');?><?=$site['domain'];?>/setting/ads">广告管理</a></li>
			</ul>
			<div class="hackbox"></div>
			<h3>选择样式模版</h3>
			<ul id="listskins" class="listTemplate">
			<? foreach ($skins as $k => $skin):?>
            	<li><a id="skin_<?=$k;?>" href="javascript:;void(0);" onclick="aj_preview_siteskin(<?=$k;?>,'<?=gurl('data/upload_pic');?>/<?=$skin['background'];?>','<?=gurl('data/upload_pic');?>/<?=$skin['bannerbg'];?>', '<?=$skin['color'];?>');" title="<?=$skin['title'];?>"><img id="<?=$skin['id'];?>" src="<?=gurl('data/upload_pic');?>/<?=$skin['thumb'];?>" width="100" height="100" <? if($site['info']['skin'] == $skin['id']):?>class="skinborder"<? endif;?> alt="<?=$skin['title'];?>"/></a></li>
            <? endforeach;?>
            </ul>
			<div class="hackbox"></div>
			<p style="height:30px">
				<input type="button" value="保存" class="smallKey" onclick="aj_save_siteskin(<?=$site['id'];?>);"> <em class="cDGreen" id="skin_msg">&nbsp;</em>
			</p>
            <h3>更换背景底图</h3>
            <form action="" method="post" enctype="multipart/form-data">
			<p class="cPurple f14px">支持jpeg，gif，png格式，文件最大允许2M</p>
			<div class="upLoad"><input name="background" id="background" type="file" style="border:1px solid #CCCCCC; height:25px \0; margin-bottom:4px;" /> <input name="dosubmit" id="dosubmit" class="smallKey" type="submit" value="确定" /></div>
			</form>	
			<div class="hackbox"></div>
            
			<h3>更换链接颜色</h3>
			<form action="" method="post">
			<div class="colorLink">
            	<p id="pageColorViews" style="background:<? if($site["info"]["color"] == ""):?>#000<? else:?><?=$site["info"]["color"];?><? endif;?>;"></p>
                <span id="chang_color"><a href="javascript:;" onclick="colorSelect('nowColor','pageColorViews',event)" class="f14px">更换颜色</a></span>
                <div id="palette class="colordisc"></div>
            </div>
            <input type="hidden" value="" name="nowColor" id="nowColor" />
            </form>
			<div class="blank8"></div>
		</div>
	</div>
		<div class="smallTip">
			<h3>提醒</h3>
			<ul>
				<li>1.商业使用(品牌、名人、公司)可申请认证，<a href="<?=gurl('about/contact');?>" >联系热闹网客服</a>。</li>
				<li>2.遇到恶意成员，<a href="<?=gurl('about/ad');?>" >联系热闹网举报</a>。</li>
			</ul>
		</div>
	<div class="hackbox"></div>
</div>

<script>
//调色板
function colorSelect(now,page,e){
 if(document.getElementById("colorBoard")){
  return;
 }
 //关于出现位置
 e=e||event;
 var scrollpos = getScrollPos();
 var l = scrollpos.l + e.clientX + 30;
    var t = scrollpos.t + e.clientY + 0;
    if (l > getBody().clientWidth-253){
        l = getBody().clientWidth-253;
    }
 //创建DOM
 var nowColor = document.getElementById(now);
 var pageColorViews = document.getElementById(page);
 var ColorHex=new Array('00','33','66','99','CC','FF');
 var SpColorHex=new Array('FF0000','00FF00','0000FF','FFFF00','00FFFF','FF00FF');
 var colorBank = document.createElement("div");
 colorBank.setAttribute("id","colorBank");
 var colorViews = document.createElement("div");
 colorViews.setAttribute("id","colorViews");
 var colorInput = document.createElement("input");
 colorInput.setAttribute("id","colorInput");
 colorInput.setAttribute("type","text");
 colorInput.setAttribute("disabled","disabled");
 var colorClose = document.createElement("input");
 colorClose.setAttribute("id","colorClose");
 colorClose.setAttribute("value","取消");
 colorClose.setAttribute("type","button");
 colorClose.onclick=function(){document.body.removeChild(colorBoard)};
 var colorBoard =document.createElement("div");
 colorBoard.id="colorBoard";
 colorBoard.style.left = l+"px";
 colorBoard.style.top = t+ "px";
 colorBoard.appendChild(colorViews);
 colorBoard.appendChild(colorInput);
 colorBoard.appendChild(colorClose);
 colorBoard.appendChild(colorBank);
 document.body.appendChild(colorBoard);
 
 //循环出调色板
 for(b=0;b<6;b++){
  for(a=0;a<3;a++){
   for(i=0;i<6;i++){
    colorItem = document.createElement("div");
    colorItem.style.backgroundColor="#"+ColorHex[a]+ColorHex[i]+ColorHex[b];
    colorBank.appendChild(colorItem);
   }    
  }
 }
 for(b=0;b<6;b++){
  for(a=3;a<6;a++){
   for(i=0;i<6;i++){
    colorItem = document.createElement("div");
    colorItem.style.backgroundColor="#"+ColorHex[a]+ColorHex[i]+ColorHex[b];
    colorBank.appendChild(colorItem);
   }    
  }
 }
 for(i=0;i<6;i++){
  colorItem = document.createElement("div");
  colorItem.style.backgroundColor="#"+ColorHex[0]+ColorHex[0]+ColorHex[0];
  colorBank.appendChild(colorItem);
 }
 for(i=0;i<6;i++){
  colorItem = document.createElement("div");
  colorItem.style.backgroundColor="#"+ColorHex[i]+ColorHex[i]+ColorHex[i];
  colorBank.appendChild(colorItem);
 }
 for(i=0;i<6;i++){
  colorItem = document.createElement("div");
  colorItem.style.backgroundColor="#"+SpColorHex[i];
  colorBank.appendChild(colorItem);
 }
 var colorItems = colorBank.getElementsByTagName("div");
 for(i=0; i<colorItems.length;i++){
  colorItems[i].onmouseover = function(){
   a = this.style.backgroundColor;
   if(a.length>7){
    a = formatRgb(a);//
   }
   colorViews.style.background = a.toUpperCase();
   colorInput.value = a.toUpperCase();
  }
  colorItems[i].onclick = function(){
   a = this.style.backgroundColor;
   if(a.length>7){
    a = formatRgb(a);//
   }
   nowColor.value = a.toUpperCase();
   pageColorViews.style.background = a.toUpperCase();
  // alert(nowColor.value);
  //触发ajax更改颜色
  //=======================================
   aj_change_linkcolor(<?=$site["id"];?>, nowColor.value);
  //=======================================
   document.body.removeChild(colorBoard);
  }
 }
 
}
//格式化函数
function formatRgb(rgb){
 rgb = rgb.replace("rgb","");rgb = rgb.replace("(","");rgb = rgb.replace(")","");
 format = rgb.split(",");
 a = eval(format[0]).toString(16);
 b = eval(format[1]).toString(16);
 c = eval(format[2]).toString(16);
 rgb = "#"+checkFF(a)+checkFF(b)+checkFF(c);
 function checkFF(str){
  if(str.length == 1){
   str = str+""+str;
   return str;
  }else{
   return str;
  }
 }
 return rgb;
}
//getBody()
function getBody(){
    var Body;
    if (typeof document.compatMode != 'undefined'  &&  document.compatMode != 'BackCompat') {
       Body = document.documentElement;
    }
    else if (typeof document.body != 'undefined') {
       Body = document.body;
    }
    return Body;
}
//scrollPos
function getScrollPos(){
  var t,l;
  if (typeof window.pageYOffset != 'undefined'){
    t = window.pageYOffset;
    l = window.pageXOffset;
  }
  else{
   t = getBody().scrollTop;
   l = getBody().scrollLeft;
  }
  return {t:t,l:l};
}

</script>

